package com.encyclopedia.controller;

import com.encyclopedia.domain.vo.PlantInfoVo;
import com.encyclopedia.result.JsonRequest;
import com.encyclopedia.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author MaLiang
 * @version 1.0
 * @date 2024-05-04 19:52
 */
@RestController
@RequestMapping("/article/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    /**
     * 查看修改文章列表
     * @return
     */
    @GetMapping("/list")
    public JsonRequest getInfoArticle(){
        return JsonRequest.success(articleService.getInfoArticle());
    }

    /**
     * 回显
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public PlantInfoVo getArticleById(@PathVariable Integer id){
        return articleService.getArticleById(id);
    }

    /**
     * 确认修改
     * @param plantInfoVo
     * @return
     */
    @PutMapping("/pass")
    public int updateArticleById(@RequestBody PlantInfoVo plantInfoVo){
        return articleService.updateArticleById(plantInfoVo);
    }
    @DeleteMapping("/{ids}")
    public JsonRequest deleteArticleById(@PathVariable("ids") Integer ids){
        return articleService.deleteArticleById(ids);
    }

}
